package com.hejr.springboot2_002.service.impl;

import com.hejr.springboot2_002.entity.User;
import com.hejr.springboot2_002.service.IUserService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("userService")
@Data
public class UserServiceImpl implements IUserService {


    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public Object addUser(String userName) {
        int ret = jdbcTemplate.update("insert into TB_USER values(null,?);", userName);
        return ret;
    }

    @Override
    public List<User> findUserList() {
        return jdbcTemplate.queryForList("select * from TB_USER T", User.class);
    }
}
